package priv.lirenhe.dissertation.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import priv.lirenhe.dissertation.data_generator.DataHtml;

@Controller
public class DataHtmlController {
	private final static String webPageShowerJsp = "webPageShower";
	
	@RequestMapping("/query_data")
	public ModelAndView queryDataGetter(HttpServletRequest request,HttpServletResponse response){
		System.out.println("queryDataGetter 执行!");
		
		ModelAndView modelAndView = null;
		
		List<String> list_Value = null;
				
		String queryStr = null;
		String pageIndex = null;
		
		queryStr = request.getParameter("queryStr");
		pageIndex = request.getParameter("pageIndex");
		
		System.out.println("queryDataGetter"+queryStr);
		
		if(queryStr != null){
			if(pageIndex == null){
				pageIndex = "1";
			}
			list_Value = DataHtml.getQueryData(queryStr, new Integer(pageIndex));
			if(list_Value != null && !list_Value.isEmpty()){
				for(String str : list_Value){
					System.out.println("----------"+str);
				}
			}else{
				System.out.println("xxxx no rows xxxx");
			}
		}
		
		
		modelAndView = new ModelAndView();
		modelAndView.addObject("list_value", list_Value);
		modelAndView.setViewName(webPageShowerJsp);
		
		return modelAndView;
		
	}
	
}
